<template>
    
    <popup ref="popupRef"
           width="830px"
           :async="true"
           custom-class="body-padding"
           title="提交打单信息"
           @confirm="handleConfirm"
           @close="handleClose">
        
        <el-form ref="formRef" class="pl-3 mb-6" :model="requestBlackMail" label-width="90px" inline>
            <div class="justify-center">
                
                <el-form-item label="物流公司:" prop="logisticCompany"
                              :rules="[{required: true, message:'物流公司不可为空',trigger:'change'}]">
                    
                    <el-input class="w-64" v-model="requestBlackMail.logisticCompany"
                              placeholder="请输入物流公司"></el-input>
                </el-form-item>
                
                <el-form-item label="物流单号:" prop="logisticNumber"
                              :rules="[{required: true, message:'物流单号不可为空',trigger:'change'}]">
                    <el-input class="w-64" v-model="requestBlackMail.logisticNumber"
                              placeholder="请输入物流单号"></el-input>
                </el-form-item>
            
            </div>
        
        
        </el-form>
    
    
    </popup>
</template>

<script lang='ts' setup>


// 提交物流信息
import {UnwrapNestedRefs} from "@vue/reactivity";
import BlackmailShipping from "@/api/afterSale/warehouse/request/BlackmailShipping";
import feedback from "@/utils/feedback";
import {producers} from "@/api/system/SystemConfigService";


const popupRef = shallowRef()
const formRef = shallowRef()
let requestBlackMail: UnwrapNestedRefs<BlackmailShipping> = reactive(new BlackmailShipping)


/**
 * 打开模拟数据
 *
 * @author 徐寿春
 * 2023/5/12 16:36
 */
function open(val: BlackmailShipping) {
    for (let valKey in val) {
        //@ts-ignore
        requestBlackMail[valKey] = val[valKey]
    }
    
    popupRef.value.open()
}


/**
 * 关闭当前
 */
function handleClose() {
    emit("close")
}


/**
 * 提交数据
 *
 * @author 徐寿春
 * 2023/5/10 11:36
 */
function handleConfirm() {
    
    formRef.value.validate().then(() => {
        producers(requestBlackMail).then(() => {
            feedback.notifySuccess("模拟打单发送成功")
            emit("confirm")
            popupRef.value.close()
        })
    })
    
    
}


const emit = defineEmits(['confirm', 'close'])
defineExpose({
    open
})


</script>
